package com.quicks.beauty.server.service;

import com.quicks.beauty.core.dao.BannersMapper;
import com.quicks.beauty.core.entity.Banners;
import com.quicks.beauty.core.entity.BannersExample;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.stream.Collectors;

@Service
public class BannerService {

    @Autowired
    private BannersMapper bannersMapper;

    public List<Banners> getBannerList(){

        BannersExample example = new BannersExample();
        example.createCriteria().andDeletedEqualTo(0)
                .andStatesEqualTo(0);
        example.setOrderByClause("numbers asc,create_time desc");
        List<Banners> list = bannersMapper.selectByExample(example);
        if (!list.isEmpty()) {
            List<Banners> collect = list.stream().limit(10).collect(Collectors.toList());
            list = collect;
        }
        return list;
    }
}
